<%@page import="com.wanmait.cookbook.vo.Admin"%>
<%@page import="com.wanmait.cookbook.vo.Userinfo"%>
<%@page import="com.wanmait.cookbook.vo.Pager"%>
<%@page import="com.wanmait.cookbook.vo.Cookbook"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%String path = request.getContextPath(); %>
<jsp:include page="/manage/inc/head.jsp"></jsp:include>
<jsp:include page="/manage/inc/menu.jsp"></jsp:include>
<!--/sidebar-->
<div class="main-wrap">

	<div class="crumb-wrap">
		<div class="crumb-list">
			<i class="icon-font"></i><a href="<%=path%>/BackIndexServlet?action=init">首页</a><span
				class="crumb-step">&gt;</span><span class="crumb-name">管理员管理</span>
		</div>
	</div>
	<div class="search-wrap">
		<div class="search-content">
			<form action="<%=path %>/UserinfoManageServlet?action=findUserinfoByInput" id="myform" method="post">
				<table class="search-tab">
				</table>
			</form>
		</div>
	</div>
	<div class="result-wrap">

		<form name="myform" id="myform1" method="post">
			<div class="result-title">
				<div class="result-list">
				<a href="<%=path%>/manage/adminManage/addAdmin.jsp"><i class="icon-font"></i>添加管理员</a>
				</div>
			</div>
			<div class="result-content">
				<table class="result-tab" width="100%">
					<tr>
						<th>序号</th>
						<th>管理员</th>
						<th>密码</th>
						<th>状态</th>
					</tr>
					<%
							
                        List<Admin> admins =(List<Admin>)request.getAttribute("admins");
                        for(int i=0;i<admins.size();i++) {	
                     %>
					<tr id="tr<%=admins.get(i).getId()%>">
						<td><%=i+1 %></td>
						<td><%=admins.get(i).getAccount() %></td>
						<td><%=admins.get(i).getPassword() %></td>
						<td>
							<select class="setban" data-id="<%=admins.get(i).getId() %>" >
							<%if(admins.get(i).getStatus()) {%>
								<option value="0" >已启用</option>
								<option value="1" selected>未启用</option>
							<%}else{ %>
								<option value="0" selected>已启用</option>
								<option value="1" >未启用</option>
							<%} %>
							</select></td>
					</tr>
					<%
                       }
                    %>
				</table>
			</div>
		</form>
	</div>
</div>
<!--/main-->
<jsp:include page="/manage/inc/foot.jsp"></jsp:include>
<script>

 $(function(){
	
		//设置启用
		$(".result-content").on("change",".setban",function(){
		  	var val = $(this).val();
			var id = $(this).data("id"); 
		  	$.ajax({
				url:"<%=path%>/AdminServlet?action=setStatus",
				data:{id:id,val:val},
				success:function(mes){
				
			}
		});  
	}); 
		
	});
</script>